package com.jari.lg.utils;


import org.slf4j.Logger;
import org.slf4j.MDC;

import java.io.PrintWriter;
import java.io.StringWriter;


/**
 * @description 统一日志工具类
 * @date 2020/4/17 17:04
 * @author ctl
 * @version 1.0
 */
public class LogUtil {



    /**
     * 获取带格式的异常堆栈消息
     * @param e
     * @return
     */
    public static String getStackMsg(Exception e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        return sw.toString();
    }

    /**
     * 获取带格式的异常堆栈消息
     * @param e
     * @return
     */
    public static String getStackMsg(Throwable e) {

        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        return sw.toString();
    }

}
